Skip to content

Add item groups (aka creative tabs)#1866

Closed
ghost wants to merge 5 commits into
bleedingfrom
unknown repository
Closed

Add item groups (aka creative tabs)#1866
ghost wants to merge 5 commits into
bleedingfrom
unknown repository

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Jul 17, 2018

SpongeAPI | SpongeCommon | SpongeForge

  • Added ItemGroup interface, cataloged by ItemGroups
  • Added Optional<ItemGroup> getItemGroup() to BlockType and ItemType

Granted, creative tabs are not super important on the server, but it could be useful, for example, for detecting mod-added tabs.

have mercy on me, this is my first sponge pull request

*
* @return The item group or {@link Optional#empty()} otherwise
*/
Optional<ItemGroup> getItemGroup();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this method - it be can retrieved from getItem() instead.

*
* @return The item group or {@link Optional#empty()} otherwise
*/
Optional<ItemGroup> getItemGroup();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An item can be in multiple groups.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quite possibly needs to be a Collection<ItemGroup>, since Collections.empty() is easy to call.

* Represents an item group, or creative tab.
*/
@CatalogedBy(ItemGroups.class)
public interface ItemGroup extends CatalogType, Translatable {}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Braces on different lines and leave a blank line between. Also, can the icon of the item group be exposed?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should add a method to see if an item is in this item group possibly.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, item group icons are client only.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the very least, make the class ending brace on a new line and leave an empty line in the middle.


public static final ItemGroup TRANSPORTATION = DummyObjectProvider.createFor(ItemGroup.class, "TRANSPORTATION");

// SORTFIELDS:OFF
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You missed the SEARCH item group.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, SEARCH, along with HOTBAR and INVENTORY, were skipped because they are not so much item groups as they are creative tabs.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you attempting to expose the tab itself, for say, GUI click events.

Or are you attempting to expose the property of items to belong to a creative tab?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, just exposing the property of items to belong to an item group.

Copy link
Copy Markdown
Member

@gabizou gabizou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quite possibly could be named ItemCollection instead of ItemGroup. I'm impartial to either name, but it is something we can expose at least in writing but without any functionality.

* Represents an item group, or creative tab.
*/
@CatalogedBy(ItemGroups.class)
public interface ItemGroup extends CatalogType, Translatable {}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the very least, make the class ending brace on a new line and leave an empty line in the middle.

import org.spongepowered.api.util.annotation.CatalogedBy;

/**
* Represents an item group, or creative tab.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would this compare to being used? They're just signified by where they show on clients? There's otherwise no other usable functionality to gain from this, right?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should document by answering these questions in some sense. That will fill out the javadoc for this class.

import org.spongepowered.api.util.generator.dummy.DummyObjectProvider;

/**
* An enumeration of all possible {@link ItemGroup}s in vanilla minecraft.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe phrase it as An enumeration of the known vanilla {@link ItemGroup}s in Minecraft. Mods may change and/or introduce new groups at runtime.

*
* @return The item group or {@link Optional#empty()} otherwise
*/
Optional<ItemGroup> getItemGroup();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quite possibly needs to be a Collection<ItemGroup>, since Collections.empty() is easy to call.

@ghost ghost changed the title Add item groups (aka creative tabs) [WIP] Add item groups (aka creative tabs) Jul 17, 2018
@ghost
Copy link
Copy Markdown
Author

ghost commented Jul 19, 2018

~wip

@ghost ghost changed the title [WIP] Add item groups (aka creative tabs) Add item groups (aka creative tabs) Jul 19, 2018
@ghost
Copy link
Copy Markdown
Author

ghost commented Jul 20, 2018

~qa

@ryantheleach
Copy link
Copy Markdown
Contributor

ryantheleach commented Jul 20, 2018

@gbui Can you offer some usecases?

At the moment, without any sample usecases, or user stories, I'm not sure whether this API is sufficient or not.

I like that you have the possibility for an item to be in multiple groups.

@gabizou I'm not sold on ItemCollection as a name, it adds confusion with Java's Collections to make it seem like it's related to the Collections API / interfaces / classes.

@XakepSDK
Copy link
Copy Markdown

Why just not name it ItemGroup -> CreativeTab? ItemGroup may be confusing with 1.13 item tags.

@ghost
Copy link
Copy Markdown
Author

ghost commented Jul 20, 2018

@ryantheleach A sample usecase could be creating an in-game shopping catalog, organized by item group. This would make it easier for players to navigate the interface (which in this case would be an inventory "GUI").

@XakepSDK I went with ItemGroup since I'm just exposing the property of items to belong to an item group. CreativeTab is specific to the client side, while ItemGroup is a more general term that makes more sense on the server side.

@kashike
Copy link
Copy Markdown
Contributor

kashike commented Jul 20, 2018

@XakepSDK It's worth noting that we've renamed CreativeTabs to ItemGroup in MCP.

@ryantheleach
Copy link
Copy Markdown
Contributor

@gbui That makes sense to me. Thanks.

@gabizou gabizou added branch: bleeding api: 8 (u) version: 1.16 (unsupported since Oct 17th 2023) labels Aug 30, 2018
@Zidane Zidane self-assigned this Feb 4, 2019
@ghost ghost closed this Jul 30, 2019
@ghost ghost deleted the feature/itemgroups branch July 30, 2019 05:05
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: 8 (u) version: 1.16 (unsupported since Oct 17th 2023) status: needs review status: needs testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants